From 1637a9c55b9f4eb3c3e842b8baeb1de4dbf6d62a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 26 Feb 2004 21:40:09 +0000 Subject: [PATCH] New convenience API to construct simple text combos, implemented by Damon Thu Feb 26 22:20:44 2004 Matthias Clasen * gtk/gtkcomboboxentry.h: * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New convenience API to construct simple text combos, implemented by Damon Chaplin. * tests/testcombo.c: Use gtk_combo_box_entry_new_text. --- ChangeLog | 13 +++++++++ ChangeLog.pre-2-10 | 13 +++++++++ ChangeLog.pre-2-4 | 13 +++++++++ ChangeLog.pre-2-6 | 13 +++++++++ ChangeLog.pre-2-8 | 13 +++++++++ docs/reference/ChangeLog | 4 +++ docs/reference/gtk/gtk-sections.txt | 1 + gtk/gtkcombobox.c | 5 ++-- gtk/gtkcomboboxentry.c | 30 ++++++++++++++++++++ gtk/gtkcomboboxentry.h | 3 ++ tests/testcombo.c | 43 +++++++++++------------------ 11 files changed, 122 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index e6d34c2a81..7b3b32aa4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Thu Feb 26 22:20:44 2004 Matthias Clasen + + * gtk/gtkcomboboxentry.h: + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New + convenience API to construct simple text combos, implemented by + Damon Chaplin. + + * tests/testcombo.c: Use gtk_combo_box_entry_new_text. + +Thu Feb 26 22:19:29 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_new_text): Improve the docs. + Thu Feb 26 15:43:43 2004 Owen Taylor * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e6d34c2a81..7b3b32aa4e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Thu Feb 26 22:20:44 2004 Matthias Clasen + + * gtk/gtkcomboboxentry.h: + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New + convenience API to construct simple text combos, implemented by + Damon Chaplin. + + * tests/testcombo.c: Use gtk_combo_box_entry_new_text. + +Thu Feb 26 22:19:29 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_new_text): Improve the docs. + Thu Feb 26 15:43:43 2004 Owen Taylor * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e6d34c2a81..7b3b32aa4e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +Thu Feb 26 22:20:44 2004 Matthias Clasen + + * gtk/gtkcomboboxentry.h: + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New + convenience API to construct simple text combos, implemented by + Damon Chaplin. + + * tests/testcombo.c: Use gtk_combo_box_entry_new_text. + +Thu Feb 26 22:19:29 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_new_text): Improve the docs. + Thu Feb 26 15:43:43 2004 Owen Taylor * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e6d34c2a81..7b3b32aa4e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Thu Feb 26 22:20:44 2004 Matthias Clasen + + * gtk/gtkcomboboxentry.h: + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New + convenience API to construct simple text combos, implemented by + Damon Chaplin. + + * tests/testcombo.c: Use gtk_combo_box_entry_new_text. + +Thu Feb 26 22:19:29 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_new_text): Improve the docs. + Thu Feb 26 15:43:43 2004 Owen Taylor * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e6d34c2a81..7b3b32aa4e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Thu Feb 26 22:20:44 2004 Matthias Clasen + + * gtk/gtkcomboboxentry.h: + * gtk/gtkcomboboxentry.c (gtk_combo_box_entry_new_text): New + convenience API to construct simple text combos, implemented by + Damon Chaplin. + + * tests/testcombo.c: Use gtk_combo_box_entry_new_text. + +Thu Feb 26 22:19:29 2004 Matthias Clasen + + * gtk/gtkcombobox.c (gtk_combo_box_new_text): Improve the docs. + Thu Feb 26 15:43:43 2004 Owen Taylor * gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index f1dcc7386d..a38ac95561 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +Thu Feb 26 22:18:21 2004 Matthias Clasen + + * gtk/gtk-sections.txt: Add gtk_combo_box_entry_new_text. + Thu Feb 26 21:41:25 2004 Matthias Clasen * gtk/gtk-sections.txt: Add gtk_rc_reset_styles. diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 05265feef6..4f30665c2a 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -705,6 +705,7 @@ gtk_combo_box_get_type GtkComboBoxEntry gtk_combo_box_entry_new gtk_combo_box_entry_new_with_model +gtk_combo_box_entry_new_text gtk_combo_box_entry_set_text_column gtk_combo_box_entry_get_text_column diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c index 1ae57c59b7..f02031ad81 100644 --- a/gtk/gtkcombobox.c +++ b/gtk/gtkcombobox.c @@ -2842,9 +2842,10 @@ gtk_combo_box_get_model (GtkComboBox *combo_box) * * Convenience function which constructs a new text combo box, which is a * #GtkComboBox just displaying strings. If you use this function to create - * a text combo box, you only want to manipulate it's data source with the + * a text combo box, you should only manipulate its data source with the * following convenience functions: gtk_combo_box_append_text(), - * gtk_combo_box_insert_text() and gtk_combo_box_prepend_text(). + * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and + * gtk_combo_box_remove_text(). * * Return value: A new text combo box. * diff --git a/gtk/gtkcomboboxentry.c b/gtk/gtkcomboboxentry.c index a21e73f823..25625f5125 100644 --- a/gtk/gtkcomboboxentry.c +++ b/gtk/gtkcomboboxentry.c @@ -337,3 +337,33 @@ gtk_combo_box_entry_mnemonic_activate (GtkWidget *widget, return TRUE; } + + +/* convenience API for simple text combos */ + +/** + * gtk_combo_box_entry_new_text: + * + * Convenience function which constructs a new editable text combo box, which + * is a #GtkComboBoxEntry just displaying strings. If you use this function to + * create a text combo box, you should only manipulate its data source with + * the following convenience functions: gtk_combo_box_append_text(), + * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and + * gtk_combo_box_remove_text(). + * + * Return value: A new text #GtkComboBoxEntry. + * + * Since: 2.4 + */ +GtkWidget * +gtk_combo_box_entry_new_text (void) +{ + GtkWidget *entry_box; + GtkListStore *store; + + store = gtk_list_store_new (1, G_TYPE_STRING); + + entry_box = gtk_combo_box_entry_new_with_model (GTK_TREE_MODEL (store), 0); + + return entry_box; +} diff --git a/gtk/gtkcomboboxentry.h b/gtk/gtkcomboboxentry.h index 9b120427a2..8955426b9e 100644 --- a/gtk/gtkcomboboxentry.h +++ b/gtk/gtkcomboboxentry.h @@ -65,6 +65,9 @@ void gtk_combo_box_entry_set_text_column (GtkComboBoxEntry *entry_box, gint text_column); gint gtk_combo_box_entry_get_text_column (GtkComboBoxEntry *entry_box); +/* convenience -- text */ +GtkWidget *gtk_combo_box_entry_new_text (void); + G_END_DECLS diff --git a/tests/testcombo.c b/tests/testcombo.c index 485fe1f3f2..f5a02c4543 100644 --- a/tests/testcombo.c +++ b/tests/testcombo.c @@ -165,33 +165,21 @@ create_blaat () return GTK_TREE_MODEL (store); } -static GtkTreeModel * -create_text_store () +static void +setup_combo_entry (GtkWidget *entry_box) { - GtkTreeIter iter; - GtkListStore *store; - - store = GTK_LIST_STORE (gtk_list_store_new (1, G_TYPE_STRING)); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "dum de dum", -1); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "la la la", -1); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "la la la dum de dum la la la la la la boom de da la la", -1); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "bloop", -1); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "bleep", -1); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, 0, "klaas", -1); - - return GTK_TREE_MODEL (store); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "dum de dum"); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "la la la"); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "la la la dum de dum la la la la la la boom de da la la"); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "bloop"); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "bleep"); + gtk_combo_box_append_text (GTK_COMBO_BOX (entry_box), + "klaas"); } int @@ -302,7 +290,8 @@ main (int argc, char **argv) gtk_container_set_border_width (GTK_CONTAINER (boom), 5); gtk_container_add (GTK_CONTAINER (tmp), boom); - comboboxtext = gtk_combo_box_entry_new_with_model (create_text_store (), 0); + comboboxtext = gtk_combo_box_entry_new_text (); + setup_combo_entry (comboboxtext); gtk_container_add (GTK_CONTAINER (boom), comboboxtext); /* done */ -- 2.30.2